home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / gateway.idb / usr / WebFace / Source / 20-NetworkServices / dhcp / dhcp-leases.frm.z / dhcp-leases.frm
Encoding:
Text File  |  1997-07-30  |  2.4 KB  |  78 lines

  1. #!/usr/bin/perl5
  2. #
  3. # dhcp-leases.cgi
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20. # $Id: dhcp-leases.frm,v 1.16 1997/04/17 21:22:56 shotes Exp $
  21.  
  22. BEGIN { require "/usr/WebFace/lib/CGI.pm"; import CGI; }
  23. require "/usr/OnRamp/lib/OnRamp.pm";
  24.  
  25. $query = new CGI;
  26.  
  27. $title = "DHCP Leases";
  28.  
  29. print $query->header;
  30. &title_block($title);
  31.  
  32. sub error {
  33.     &error_block($_[0]);
  34.     exit 0;
  35. }
  36.  
  37. $srv_off = system ("/etc/chkconfig", "proclaim_server");
  38. if ($srv_off) {
  39.     &error("This system is not configured to be a DHCP server.");
  40. }
  41.  
  42. $lsf = "/var/dhcp/etherToIP";
  43. open(LEASE, $lsf) || &error("There are no current address leases.");
  44.  
  45. &header_block($title);
  46.  
  47. print "<center><table cellpadding=5 width=450>";
  48. print "<tr><th align=left>Hostname<th align=left>Domain<th align=left>
  49.         IP Address<th align=left>Expiration";
  50. while(<LEASE>) {
  51.     chop;
  52.     ($ether, $ip, $host, $expiry) = split(/\s+/);
  53.     ($hname, @domain) = split(/\./, $host);
  54.     $domain = join('.', @domain);
  55.     if ($expiry) {
  56.     if (time < $expiry) {
  57.         @gt = localtime $expiry;
  58.         $date = sprintf "%02d/%02d/%02d", $gt[4]+1, $gt[3], $gt[5];
  59.         $fol = "AM";
  60.         if ($gt[2] == 12) { $fol = "PM"; }
  61.         if ($gt[2] > 12) { $gt[2] -= 12; $fol = "PM"; }
  62.         if ($gt[1] < 10) { $gt[1] = "0$gt[1]"; }
  63.         $time = "$gt[2]:$gt[1] $fol";
  64.         print "<tr><td align=left>$hname<td align=left>$domain" .
  65.         "<td align=left>$ip<td align=left>$time, $date</tr>\n";
  66.     } else {
  67.         print "<tr><td align=left>$hname<td align=left>$domain" .
  68.         "<td align=left>$ip<td align=left>Expired</tr>\n";
  69.     }
  70.     }
  71.     else {
  72.     print "<tr><td align=left>$hname<td align=left>$domain" .
  73.         "<td align=left>$ip<td align=left>Negotiating</tr>\n";
  74.     }
  75. }
  76. close(LEASE);
  77. print "</table></center>\n";
  78.